<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
	#parent	{width: 600px; height: 20px; background: #CCC; position: relative;  margin: 10px auto;}	
	#div1 {width: 20px;	height: 20px; background: yellow; position:absolute; left: 0;top: 0;	}
	#div2 {width: 400px; height: 300px; border: 1px solid black; position: relative; overflow: hidden}
	#div3 {position: absolute; left: 0;top: 0;}
</style>
<script>
window.onload = function()
{
		var oDiv = document.getElementById('div1');
		var oParent = document.getElementById('parent');
	
		var oDiv2 = document.getElementById('div2');
		var oDiv3 = document.getElementById('div3');
	
		var disX =0 ;
		var disY = 0;
	
		oDiv.onmousedown= function(ev)
		{
				//clientX clientY 鼠标坐标
				var oEvent = ev||event;
				disX = oEvent.clientX- oDiv.offsetLeft ;
				disY = oEvent.clientY -oDiv.offsetTop ;

				document.onmousemove= function(ev)
				{
						var oEvent = ev||event;
						var left = oEvent.clientX - disX;
						var top = oEvent.clientY - disY;
						
						if(left<0)
						{
								left = 0;
						}
						if(left > oParent.offsetWidth -oDiv.offsetWidth)
						{
								left = oParent.offsetWidth -oDiv.offsetWidth;
						}
						if(top<0)
						{
								top = 0;
						}
						if(top > oParent.offsetHeight -oDiv.offsetHeight)
						{
								top = oParent.offsetHeight -oDiv.offsetHeight;
						}
					
						oDiv.style.left = left + 'px';
						oDiv.style.top = top + 'px';
						
						var per = left/(oParent.offsetWidth - oDiv.offsetWidth);
						document.title = left;
						
						oDiv3 .style.top = -(oDiv3.offsetHeight - oDiv2.offsetHeight) * per + 'px';

				};
				
			document.onmouseup = function()
			{
					document.onmousemove =null;
					document.onmouseup=null;
			};
			return false;
		};
};
</script>
</head>

<body>
<div id="parent">
			<div id="div1"></div>
</div>

<div id="div2">
	<div id="div3">
		  Organization: testBATBAT789 Created 
2018 02-07 01:19:47.331   User: BATBAT1@testBATBAT789 Created! 
2018 02-07 01:19:47.383  Begin to Post Data! 
2018 02-07 01:19:47.385  Posting... 
2018 02-07 01:19:47.409  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980787
2018 02-07 01:19:55.155    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 1 SoapClient Status: 0 CostTime: 7745 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980787
2018 02-07 01:19:57.414  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980797
2018 02-07 01:20:04.271    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 2 SoapClient Status: 0 CostTime: 6856 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980797
2018 02-07 01:20:07.416  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980807
2018 02-07 01:20:14.030    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 3 SoapClient Status: 0 CostTime: 6613 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980807
2018 02-07 01:20:17.642  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980817
2018 02-07 01:20:49.101    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 4 SoapClient Status: 0 CostTime: 31681 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980817
2018 02-07 01:20:49.104  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980849
2018 02-07 01:21:07.302    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 5 SoapClient Status: 0 CostTime: 18196 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980849
2018 02-07 01:21:07.303  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980867
2018 02-07 01:21:24.313    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 6 SoapClient Status: 0 CostTime: 17008 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980867
2018 02-07 01:21:24.315  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980884
2018 02-07 01:22:06.249    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 7 SoapClient Status: 0 CostTime: 41931 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980884
2018 02-07 01:22:06.250  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980926
2018 02-07 01:22:26.551    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 8 SoapClient Status: 0 CostTime: 20299 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980926
2018 02-07 01:22:26.553  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980946
2018 02-07 01:23:02.121    User: BATBAT1@testBATBAT789 Post Data successfully!  DataPackage 9 SoapClient Status: 0 CostTime: 35543 MS Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980946
2018 02-07 01:23:02.443  Token = 5aa6892f75a2494ab7c7bf15954195789578,TimeStamp = 1517980982

	</div>
</div>
</body>
</html>
